class Answer {
  final int id;
  final String explain;
  final String answer;

  Answer({
    required this.id,
    required this.explain,
    required this.answer,
  });

  factory Answer.fromJson(Map<String, dynamic> json) {
    return Answer(
      id: json['id'],
      explain: json['explain'],
      answer: json['answer'],
    );
  }

  // 判断是否为判断题
  bool get isJudgment {
    return answer == 'true' || answer == 'false';
  }

  // 获取格式化后的答案
  String get formattedAnswer {
    if (isJudgment) {
      return answer == 'true' ? '正确' : '错误';
    } else {
      return answer;
    }
  }
}